<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>tool_时间转换工具</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="data/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<div id="top_page"></div>

<form class="layui-form" method="post" onSubmit="return test_form();">
  <div class="layui-form-item">
    <label class="layui-form-label">输入</label>
    <div class="layui-input-block">
      <input type="text" name="date1" lay-verify="title" autocomplete="off" placeholder="请输入时间戳" class="layui-input">
    </div>
    <label class="layui-form-label">输出</label>
    <div class="layui-input-block">
      <input type="text" name="date_out" lay-verify="title" autocomplete="off" placeholder="返回日期格式" class="layui-input" readonly>
    </div>

  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button  class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>


<script src="data/layui/layui.all.js"></script>
<script src="data/jquery-2.0.2.min.js"></script>
<script type="text/javascript" language="javascript">
  // 禁止load使用缓存页面
  $.ajaxSetup ({
    cache: false //close AJAX cache
  });

  //引入公共头部
  $("#top_page").load("top.html");

</script>
<script>

  function test_form(){
    var data = $("form").serialize();


    $.ajax({
      method:'get',
      url: 'http://tool.zhaizhaiplan.com/act/index.php?act=test',
      data,
      dataType:'json',
      crossDomain:false,
      beforeSend:function(xhr){
        xhr.setRequestHeader("token",'V3_97f072c5ygp00858ed1d8033d13cf92e14dda4ed1b74');
      },
      success: function(res) {
        if(res.status != 0){
          $('input[name="date_out"]').attr('style', '');
          $('input[name="date_out"]').val(res.data);
        }else{
          $('input[name="date_out"]').attr('style', 'color:red;text-align:left');
          $('input[name="date_out"]').val(res.msg);
        }
      }
    })


    return false;
  }

</script> 
</body>
</html>

